import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/25 15:23
 */

public class Solution {
    public int subarraySum(int[] nums, int k){
        Map<Integer,Integer> map = new HashMap<>();
        map.put(0,1);

        int sum = 0,ret = 0;
        for (int x = 0; x < nums.length; x++) {
            sum += nums[x];//记录当前位置的前缀和
            ret += map.getOrDefault(sum - k,0);//统计结果
            map.put(sum,map.getOrDefault(sum,0)+1);
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            int k = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.subarraySum(nums, k));
        }
    }
}